/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.thienloc.omap.session;

import com.thienloc.omap.entity.GiaiThuong;
import org.slf4j.LoggerFactory;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author GiangLT
 */
@Stateless
public class GiaiThuongFacade extends AbstractFacade<GiaiThuong> {

    @PersistenceContext(unitName = "omapPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public GiaiThuongFacade() {
        super(GiaiThuong.class);
    }

    public void deleteByKqxsId(Long idKqxs) throws Exception {
        try {
            Query q = em.createNativeQuery("DELETE FROM giai_thuong WHERE id_kqxs = ?");

            q.setParameter(1, idKqxs);
            q.executeUpdate();
        } catch (Exception ex) {
            LoggerFactory.getLogger(GiaiThuongFacade.class.getName()).error("", ex);
            throw ex;
        }
    }
}
